package kpi.javatraining6.gnatiuk.tests;

import kpi.javatraining6.gnatiuk.src.tester.question.OwnAnswerQuestion;
import kpi.javatraining6.gnatiuk.src.tester.question.Question;
import kpi.javatraining6.gnatiuk.src.tester.user.UserProgress;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

import java.util.ArrayList;


public class UserHistoryTest {
    UserProgress userHistory;
    Question question;
    @Before
    public void setUp() throws Exception {
         userHistory = new UserProgress();
         question = new OwnAnswerQuestion("EASY", "", new ArrayList<String>(), new ArrayList<String>());
    }

    @Test
    public void testAddToAnswered() throws Exception {
         userHistory.addToAnswered(question, new ArrayList<String>());
        assertTrue("must be true", userHistory.isAnswered(question));
    }

    @Test
    public void testRemoveLastAnswered() throws Exception {
        userHistory.addToAnswered(question, new ArrayList<String>());
        userHistory.removeLastAnswered();
        assertFalse("must be false", userHistory.isAnswered(question));
    }

    @Test
    public void testIsNotAnswered() throws Exception {
        assertFalse("must be false", userHistory.isAnswered(question));
    }

    @Test
    public void testGetStatistic() throws Exception {
           userHistory.addToAnswered(question, new ArrayList<String>());
        String rez = userHistory.getStatistic();
        assertEquals("must be 0/1", "0/1", rez);
    }

    @Test
    public void testToString() throws Exception {
        assertEquals("must be same classes", String.class, userHistory.toString().getClass());
    }
}
